home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / The Hacks! / mhTV ƒ / TVSource / SourceThatMatters / General / Maynard.h < prev   
Text File  |  1998-06-21  |  5KB  |  166 lines

  1. #ifndef Maynard_H
  2. #define Maynard_H
  3. #include <MacMemory.h>
  4. #include <Math64.h>
  5.  
  6. #include "TextUtils.h"
  7. #include "Threads.h"
  8.  
  9. ///=============================================================================
  10.  
  11. #undef  TRUE
  12. #undef  FALSE
  13.  
  14. #define TRUE                1
  15. #define FALSE               0
  16. #define UNITIALIZED     (-1)
  17.  
  18. #undef  NULL
  19. #define NULL  0
  20.  
  21. ///=============================================================================
  22.  
  23. //This is true for 601, 603, 604.
  24. //May have to change for other PPC CPUs.
  25. #define kCacheBlockSize  32 
  26. #define kCacheBlockSize1 (kCacheBlockSize-1) 
  27.  
  28. ///.............................................................................
  29.  
  30. #define kStandardMovieTimeScale 600
  31.  
  32. ///.............................................................................
  33.  
  34. #define kfxTwo      0x00020000
  35. #define kfxOne      0x00010000
  36. #define kfxHalf     0x00008000
  37. #define kfxZero     0x00000000
  38. #define kfxMinusOne (-kfxOne)
  39.  
  40. ///.............................................................................
  41.  
  42. #ifndef MIN
  43.     #define MIN(x, y)     ( (x)<(y) ?(x) :(y) )
  44. #endif //MIN
  45.  
  46. #ifndef MAX
  47.     #define MAX(x, y)     ( (x)>(y) ?(x): (y) )
  48. #endif //MAX
  49.  
  50. #ifndef MIN64S
  51.     #define MIN64S(x, y)( S64Compare(x, y)<0 ?(x) :(y) )
  52. #endif //MIN
  53.  
  54. #ifndef MAX64S
  55.     #define MAX64S(x, y)( S64Compare(x, y)>0 ?(x): (y) )
  56. #endif //MAX
  57.  
  58.  
  59. #ifndef ABS
  60.     #define ABS(x)         ( (x)>=0? (x): -(x) )
  61. #endif //ABS
  62.  
  63. #ifndef SGN
  64.     #define SGN(x)         ( (x)>0? 1: ((x)<0? -1: 0) )
  65. #endif //ABS
  66.  
  67. ///.............................................................................
  68.  
  69. //Use KONST for parameters where the variable should be const, but a bonehead 
  70. //header file prevents you from declaring it const.
  71. #define KONST 
  72. #define ASM     pascal
  73. #define GLOBAL 
  74.  
  75. ///.............................................................................
  76.  
  77. typedef unsigned char   BOOL8;
  78. typedef unsigned short  BOOL16;
  79. typedef unsigned long   BOOL32;
  80. typedef BOOL32          BOOL;
  81.  
  82. typedef signed char        TRI_STATE8;
  83. typedef signed short    TRI_STATE16;
  84. typedef signed long        TRI_STATE32;
  85. typedef TRI_STATE32        TRI_STATE;
  86.  
  87. typedef char              INT8;
  88. typedef short             INT16;
  89. typedef long              INT32;
  90. typedef int               INT;
  91.     
  92. typedef unsigned char      UINT8;
  93. typedef unsigned short     UINT16;
  94. typedef unsigned long      UINT32;
  95. typedef unsigned int       UINT;
  96.     
  97. typedef signed char      SINT8;
  98. typedef signed short     SINT16;
  99. typedef signed long      SINT32;
  100. typedef signed int       SINT;
  101.  
  102. //This is for blitting to the screen using an 8byte wide register.
  103. // On CPUs that support an 8 byte wide integer register it should be 
  104. // set to that type, ie long long.
  105. // On x86 if it's possible to define a type that maps to an MMX register,
  106. // that should be used.
  107. typedef double            BLIT64;
  108.  
  109. #define BOOL1(var)        BOOL8 var :1
  110.  
  111. ///.............................................................................
  112.  
  113. #ifndef STATIC_CAST
  114. #define STATIC_CAST(     cast, expression) ((cast)(expression))
  115. #define REINTERPRET_CAST(cast, expression) ((cast)(expression))
  116. #define CONST_CAST(      cast, expression) ((cast)(expression))
  117. #endif 
  118.  
  119. ///-----------------------------------------------------------------------------
  120.  
  121. #define RETURN_ERROR2(error1, error2)                                        \
  122.     if(error1!=noErr)      return error1;                                    \
  123.     else                   return error2;                                    \
  124.  
  125. #define RETURN_ERROR3(error1, error2, error3)                                \
  126.     if(error1!=noErr)       return error1;                                    \
  127.     else if(error2!=noErr) return error2;                                    \
  128.     else                   return error3;                                    \
  129.  
  130. #define RETURN_ERROR4(error1, error2, error3, error4)                        \
  131.     if(error1!=noErr)       return error1;                                    \
  132.     else if(error2!=noErr) return error2;                                    \
  133.     else if(error3!=noErr) return error3;                                    \
  134.     else                   return error4;                                    \
  135.  
  136. #define RETURN_ERROR5(error1, error2, error3, error4, error5)                \
  137.     if(error1!=noErr)       return error1;                                    \
  138.     else if(error2!=noErr) return error2;                                    \
  139.     else if(error3!=noErr) return error3;                                    \
  140.     else if(error4!=noErr) return error4;                                    \
  141.     else                   return error5;                                    \
  142.     
  143. ///=============================================================================
  144.  
  145. #if DEBUG
  146.     #define DEBUGSTR(str) DebugStr(str)
  147.     #define FLAG_ERROR(error)                                               \
  148.         if(error!=noErr){                                                    \
  149.             Str32 zStr; NumToString(error, zStr); DebugStr(zStr);            \
  150.         }
  151.  
  152.     int mjhassert(char*, char*, int);
  153.     int imjhassert(char*, char*, int);
  154.     #define ASSERT(f)  ((void) ((f) ||  mjhassert(#f, __FILE__, __LINE__)))
  155.     #define IASSERT(f) ((void) ((f) || imjhassert(#f, __FILE__, __LINE__)))
  156. #else
  157.     #define DEBUGSTR(str)         {;}
  158.     #define FLAG_ERROR(error)    {;}
  159.     #define ASSERT(condition)    {;}
  160.     #define IASSERT(condition)    {;}
  161. #endif
  162.  
  163. ///=============================================================================
  164.  
  165. #endif //Maynard_H
  166.